package com.itcast.n1_内存调优;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @program: jvm
 * @description:
 * @author: flyduck
 * @create: 2024-10-15 17:22
 **/
@Component
public class  Test03_解决内存泄漏_定时任务调度出现内存泄露导致内存溢出{

    private int count = 0;
    private List<Object> list = new ArrayList<>();

    //@Scheduled(fixedRate = 100L)
    public void test(){
        System.out.println("定时任务调用" + ++count);
        list.add(new Outer2());
    }
}

class Outer2 {
    private byte[] bytes = new byte[1024 * 1024 * 10];
}
